<?php
require_once( 'macro.php' );
if($userId>0){
	$users = getMultiple( 'user', "userId||$userId", "userStatus||verified");
	if($users->getResultCount()>0){
		$template->message = "";
		$template->messageClass = "";
		/* navigation */
		$navArray[11]['parent']['class'] = 'active';
		$navArray[11]['child'][3]['class'] = 'active';
		$template->navArray = $navArray;
		if(isset($_POST['addCategory'])){
			if( $_POST['categoryName']!="" &&  $_POST['shortDescription']!="" ){
				$categoryName = $_POST['categoryName'];
				$categoryName = stripslashes($categoryName);
				$categorySlug = sanitizeWithDashes($categoryName);
				$shortDescription = $_POST['shortDescription'];
				$categoryDb = getDb( 'category', 'add' );
				$categoryDb->set( "categoryName||$categoryName", "categorySlug||$categorySlug", "categoryDescription||$shortDescription", "createdUserId||$userId" );
				if($categoryDb->getLastInsertedId()>0){
					$template->message = "The Category has been added Successfully!";
					$template->messageClass = "success";
				}
			}else{
				$template->message = "Catergory Name and Description are Required Parameters!";
				$template->messageClass = "error";
			}
		}
	}
}